package com.why.controller;

import com.why.domain.Group;
import com.why.service.GroupService;
import com.why.utils.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Group)表控制层
 *
 * @author makejava
 * @since 2024-06-14 19:31:21
 */
@RestController
@RequestMapping("/group")
public class GroupController {
    /**
     * 服务对象
     */
    @Resource
    private GroupService groupService;

    @PostMapping("/add")
    public Result addGroup(String groupName) {
        groupService.addGroup(groupName);
        return Result.success();
    }

    @GetMapping
    public Result getAllGroup() {
        List<Group> list = groupService.list();
        return Result.success(list);
    }

    @DeleteMapping("/{id}")
    public Result deleteGroup(@PathVariable Long id) {
        groupService.deleteGroup(id);
        return Result.success();
    }
}

